home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / program / xmsbcp11.zip / C / XMSINIT.C < prev    next >
C/C++ Source or Header  |  1997-04-13  |  2KB  |  72 lines

  1.  
  2. /* ---------------------------------------------------------------------*/
  3. /*                                    */
  4. /*    XMS Interface for Borland C/C++, Version 1.1            */
  5. /*    Developed by Tanescu A. Horatiu                    */
  6. /*    April 1997                            */
  7. /*                                    */
  8. /* ---------------------------------------------------------------------*/
  9. /*    C sources                            */
  10. /* ---------------------------------------------------------------------*/
  11. /*                                    */
  12. /*    XMSINIT.C                            */
  13. /*                                    */
  14. /*    Initialization Functions                    */
  15. /*    (_xmsdefaultcontrol, _xmsdrivercheck, _getxmsfunct, initxms)    */
  16. /*                                    */
  17. /* ---------------------------------------------------------------------*/
  18.  
  19. #include "xms.h"
  20.  
  21. #pragma inline
  22.  
  23. unsigned char xmserrno = 0;
  24. unsigned char xmsinstalled = 0;
  25.  
  26. /* default XMS control function
  27.  */
  28.  
  29. void far _xmsdefaultcontrol(void)
  30. {
  31.   asm    xor    ax, ax
  32.   asm    mov    bl, 0x80
  33.   asm    mov    xmserrno, bl
  34. }
  35.  
  36. void (far *xmscontrol)(void) = _xmsdefaultcontrol;
  37.  
  38. /* _xmsdrivercheck - determine if an XMS driver is installed
  39.  */
  40.  
  41. int _xmsdrivercheck(void)
  42. {
  43.   asm    mov    ax, 0x4300
  44.   asm    int    0x2F
  45.   asm    xor    ah, ah
  46.   asm    sub    ax, 0x80
  47.   return (!_AX);
  48. }
  49.  
  50. /* _getxmsfunct - get the address of the XMS driver's control function
  51.  */
  52.  
  53. void _getxmsfunct(void)
  54. {
  55.   asm    mov    ax, 0x4310
  56.   asm    int    0x2F
  57.   asm    mov    word ptr [xmscontrol], bx
  58.   asm    mov    word ptr [xmscontrol+2], es
  59. }
  60.  
  61. /* initxms - initialization routine
  62.    THIS ROUTINE MUST BE CALLED BEFORE ANY OTHER ROUTINE OR ALL THE OTHER
  63.    ROUTINES WILL FAIL WITH ERROR CODE 0x80.
  64.  */
  65.  
  66. int initxms(void)
  67. {
  68.   register int check = _xmsdrivercheck();
  69.   if (check) _getxmsfunct();
  70.   xmsinstalled = check;
  71.   return (check);
  72. }